/**
 * Project: happyouting-dal-activity
 * 
 * File Created at 2009-11-7
 * $Id: IbatisActivityRoleDao.java 96 2009-11-10 05:06:12Z worldmaomao $
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.alibaba.happyouting.activity.dal.dao.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alibaba.happyouting.activity.dal.dao.ActivityRoleDao;
import com.alibaba.happyouting.activity.dal.dataobject.ActivityRole;
import com.alibaba.happyouting.activity.dal.dataobject.ActivityRoleWithUserName;

/**
 * TODO Comment of IbatisActivityRoleDao
 * 
 * @author xingyue.wangxy
 */
public class IbatisActivityRoleDao extends SqlMapClientDaoSupport implements ActivityRoleDao {

    public void deleteActivityRoleById(Long id, Long uid) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        map.put("uid", uid);
        this.getSqlMapClientTemplate().delete("deleteActivityRoleById", map);
    }

    public void insertActivityRole(ActivityRole activityRole) {
        this.getSqlMapClientTemplate().insert("insertActivityRole", activityRole);
    }

    public List<ActivityRoleWithUserName> findActivityRoleWithUserName(Long id) {
        return this.getSqlMapClientTemplate().queryForList("findActivityRoleWithUserName", id);
    }

    public Integer getCountOfTheActivityRoleOfActivity(Long id, Long uid) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        map.put("uid", uid);
        return (Integer) this.getSqlMapClientTemplate().queryForObject(
                "getCountOfTheActivityRoleOfActivity", map);
    }

    public void insertBatchActivityRole(List<String> usernameList, Long activityId, Integer level) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("usernameList", usernameList);
        map.put("activityId", activityId);
        map.put("level", level);
        this.getSqlMapClientTemplate().insert("insertBatchActivityRole", map);
    }

    public void deleteBatchActivityRole(List<Long> useridList, Long activityId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("useridList", useridList);
        map.put("id", activityId);
        this.getSqlMapClientTemplate().delete("deleteBatchActivityRole", map);
    }

    public Integer getCountOfActivityRoleOfActivity(Long activityId) {
        return (Integer) this.getSqlMapClientTemplate().queryForObject(
                "getCountOfActivityRoleOfActivity", activityId);
    }
}
